using dnAnalytics.Math;
using NUnit.Framework;

namespace dnAnalytics.Tests.Math
{
    [TestFixture]
    public class ComplexMath_AtanTest
    {
        [Test]
        public void Atan()
        {
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(0.0, 1.19209289550780998537e-7)), new Complex(0.0, 1.19209289550781563226e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(0.0, -1.19209289550780998537e-7)), new Complex(0.0, -1.19209289550781563226e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(0.0, 5.0e-1)), new Complex(0.0, 5.49306144334054845698e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(0.0, -5.0e-1)), new Complex(0.0, -5.49306144334054845698e-1), 9);
            //TestHelper.TestLogRelativeError(ComplexMath.Atan(new Complex(0.0, 2.0)), new Complex(1.57079632679489661923, 5.49306144334054845698e-1), 9);
            // TestHelper.TestLogRelativeError(ComplexMath.Atan(new Complex(0.0, 8.388608e6)), new Complex(1.57079632679489661923, 1.19209289550781814689e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, 0.0)), new Complex(1.19209289550780433848e-7, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, 0.0)), new Complex(-1.19209289550780433848e-7, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, 1.19209289550780998537e-7)), new Complex(1.19209289550782127914e-7, 1.1920928955077986916e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, -1.19209289550780998537e-7)), new Complex(1.19209289550782127914e-7, -1.1920928955077986916e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, 1.19209289550780998537e-7)), new Complex(-1.19209289550782127914e-7, 1.1920928955077986916e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, -1.19209289550780998537e-7)), new Complex(-1.19209289550782127914e-7, -1.1920928955077986916e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, 5.0e-1)), new Complex(1.58945719401038988971e-7, 5.49306144334042213827e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, -5.0e-1)), new Complex(1.58945719401038988971e-7, -5.49306144334042213827e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, 5.0e-1)), new Complex(-1.58945719401038988971e-7, 5.49306144334042213827e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, -5.0e-1)), new Complex(-1.58945719401038988971e-7, -5.49306144334042213827e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, 1.0)), new Complex(7.85398193199770697311e-1, 8.3177661667193456559), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, -1.0)), new Complex(7.85398193199770697311e-1, -8.3177661667193456559), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, 1.0)), new Complex(-7.85398193199770697311e-1, 8.3177661667193456559), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, -1.0)), new Complex(-7.85398193199770697311e-1, -8.3177661667193456559), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, 2.0)), new Complex(1.57079628705846676897, 5.4930614433405168773e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, -2.0)), new Complex(1.57079628705846676897, -5.4930614433405168773e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, 2.0)), new Complex(-1.57079628705846676897, 5.4930614433405168773e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, -2.0)), new Complex(-1.57079628705846676897, -5.4930614433405168773e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, 8.388608e6)), new Complex(1.57079632679489661923, 1.19209289550781814689e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.19209289550780998537e-7, -8.388608e6)), new Complex(1.57079632679489661923, -1.19209289550781814689e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, 8.388608e6)), new Complex(-1.57079632679489661923, 1.19209289550781814689e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.19209289550780998537e-7, -8.388608e6)), new Complex(-1.57079632679489661923, -1.19209289550781814689e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, 0.0)), new Complex(4.63647609000806116214e-1, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, 0.0)), new Complex(-4.63647609000806116214e-1, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, 1.19209289550780998537e-7)), new Complex(4.63647609000810663688e-1, 9.53674316406248711098e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, -1.19209289550780998537e-7)), new Complex(4.63647609000810663688e-1, -9.53674316406248711098e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, 1.19209289550780998537e-7)), new Complex(-4.63647609000810663688e-1, 9.53674316406248711098e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, -1.19209289550780998537e-7)), new Complex(-4.63647609000810663688e-1, -9.53674316406248711098e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, 5.0e-1)), new Complex(5.53574358897045251509e-1, 4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, -5.0e-1)), new Complex(5.53574358897045251509e-1, -4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, 5.0e-1)), new Complex(-5.53574358897045251509e-1, 4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, -5.0e-1)), new Complex(-5.53574358897045251509e-1, -4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, 1.0)), new Complex(9.07887494960880386702e-1, 7.08303336014054020062e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, -1.0)), new Complex(9.07887494960880386702e-1, -7.08303336014054020062e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, 1.0)), new Complex(-9.07887494960880386702e-1, 7.08303336014054020062e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, -1.0)), new Complex(-9.07887494960880386702e-1, -7.08303336014054020062e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, 2.0)), new Complex(1.42154686100180698026, 5.00370000052531017442e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, -2.0)), new Complex(1.42154686100180698026, -5.00370000052531017442e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, 2.0)), new Complex(-1.42154686100180698026, 5.00370000052531017442e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, -2.0)), new Complex(-1.42154686100180698026, -5.00370000052531017442e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, 8.388608e6)), new Complex(1.5707963267948895138, 1.19209289550781391172e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(5.0e-1, -8.388608e6)), new Complex(1.5707963267948895138, -1.19209289550781391172e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, 8.388608e6)), new Complex(-1.5707963267948895138, 1.19209289550781391172e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-5.0e-1, -8.388608e6)), new Complex(-1.5707963267948895138, -1.19209289550781391172e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, 0.0)), new Complex(7.85398163397448309616e-1, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, 0.0)), new Complex(-7.85398163397448309616e-1, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, 1.19209289550780998537e-7)), new Complex(7.85398163397451862329e-1, 5.96046447753903580964e-8), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, -1.19209289550780998537e-7)), new Complex(7.85398163397451862329e-1, -5.96046447753903580964e-8), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, 1.19209289550780998537e-7)), new Complex(-7.85398163397451862329e-1, 5.96046447753903580964e-8), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, -1.19209289550780998537e-7)), new Complex(-7.85398163397451862329e-1, -5.96046447753903580964e-8), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, 5.0e-1)), new Complex(8.47575660670829027131e-1, 2.38877861256859090363e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, -5.0e-1)), new Complex(8.47575660670829027131e-1, -2.38877861256859090363e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, 5.0e-1)), new Complex(-8.47575660670829027131e-1, 2.38877861256859090363e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, -5.0e-1)), new Complex(-8.47575660670829027131e-1, -2.38877861256859090363e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, 1.0)), new Complex(1.01722196789785136772, 4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, -1.0)), new Complex(1.01722196789785136772, -4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, 1.0)), new Complex(-1.01722196789785136772, 4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, -1.0)), new Complex(-1.01722196789785136772, -4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, 2.0)), new Complex(1.33897252229449356112, 4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, -2.0)), new Complex(1.33897252229449356112, -4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, 2.0)), new Complex(-1.33897252229449356112, 4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, -2.0)), new Complex(-1.33897252229449356112, -4.0235947810852509365e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, 8.388608e6)), new Complex(1.57079632679488240838, 1.19209289550780120623e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(1.0, -8.388608e6)), new Complex(1.57079632679488240838, -1.19209289550780120623e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, 8.388608e6)), new Complex(-1.57079632679488240838, 1.19209289550780120623e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-1.0, -8.388608e6)), new Complex(-1.57079632679488240838, -1.19209289550780120623e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, 0.0)), new Complex(1.10714871779409050302, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, 0.0)), new Complex(-1.10714871779409050302, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, 1.19209289550780998537e-7)), new Complex(1.10714871779409163989, 2.38418579101561500148e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, -1.19209289550780998537e-7)), new Complex(1.10714871779409163989, -2.38418579101561500148e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, 1.19209289550780998537e-7)), new Complex(-1.10714871779409163989, 2.38418579101561500148e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, -1.19209289550780998537e-7)), new Complex(-1.10714871779409163989, -2.38418579101561500148e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, 5.0e-1)), new Complex(1.12655644083482234874, 9.6415620202996167238e-2), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, -5.0e-1)), new Complex(1.12655644083482234874, -9.6415620202996167238e-2), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, 5.0e-1)), new Complex(-1.12655644083482234874, 9.6415620202996167238e-2), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, -5.0e-1)), new Complex(-1.12655644083482234874, -9.6415620202996167238e-2), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, 1.0)), new Complex(1.17809724509617246442, 1.73286795139986327354e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, -1.0)), new Complex(1.17809724509617246442, -1.73286795139986327354e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, 1.0)), new Complex(-1.17809724509617246442, 1.73286795139986327354e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, -1.0)), new Complex(-1.17809724509617246442, -1.73286795139986327354e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, 2.0)), new Complex(1.31122326967163514335, 2.38877861256859090363e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, -2.0)), new Complex(1.31122326967163514335, -2.38877861256859090363e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, 2.0)), new Complex(-1.31122326967163514335, 2.38877861256859090363e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, -2.0)), new Complex(-1.31122326967163514335, -2.38877861256859090363e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, 8.388608e6)), new Complex(1.57079632679486819752, 1.19209289550775038425e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(2.0, -8.388608e6)), new Complex(1.57079632679486819752, -1.19209289550775038425e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, 8.388608e6)), new Complex(-1.57079632679486819752, 1.19209289550775038425e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-2.0, -8.388608e6)), new Complex(-1.57079632679486819752, -1.19209289550775038425e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, 0.0)), new Complex(1.57079620758560706845, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, 0.0)), new Complex(-1.57079620758560706845, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, 1.19209289550780998537e-7)), new Complex(1.57079620758560706845, 1.69406589450857303051e-21), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, -1.19209289550780998537e-7)), new Complex(1.57079620758560706845, -1.69406589450857303051e-21), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, 1.19209289550780998537e-7)), new Complex(-1.57079620758560706845, 1.69406589450857303051e-21), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, -1.19209289550780998537e-7)), new Complex(-1.57079620758560706845, -1.69406589450857303051e-21), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, 5.0e-1)), new Complex(1.57079620758560706845, 7.10542735760087564097e-15), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, -5.0e-1)), new Complex(1.57079620758560706845, -7.10542735760087564097e-15), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, 5.0e-1)), new Complex(-1.57079620758560706845, 7.10542735760087564097e-15), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, -5.0e-1)), new Complex(-1.57079620758560706845, -7.10542735760087564097e-15), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, 1.0)), new Complex(1.57079620758560706845, 1.42108547152015998206e-14), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, -1.0)), new Complex(1.57079620758560706845, -1.42108547152015998206e-14), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, 1.0)), new Complex(-1.57079620758560706845, 1.42108547152015998206e-14), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, -1.0)), new Complex(-1.57079620758560706845, -1.42108547152015998206e-14), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, 2.0)), new Complex(1.57079620758560706846, 2.84217094304019879509e-14), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, -2.0)), new Complex(1.57079620758560706846, -2.84217094304019879509e-14), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, 2.0)), new Complex(-1.57079620758560706846, 2.84217094304019879509e-14), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, -2.0)), new Complex(-1.57079620758560706846, -2.84217094304019879509e-14), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, 8.388608e6)), new Complex(1.57079626719025184384, 5.96046447753904838278e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(8.388608e6, -8.388608e6)), new Complex(1.57079626719025184384, -5.96046447753904838278e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, 8.388608e6)), new Complex(-1.57079626719025184384, 5.96046447753904838278e-8), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Atan(new Complex(-8.388608e6, -8.388608e6)), new Complex(-1.57079626719025184384, -5.96046447753904838278e-8), 9);
        }
    }
}